from django.shortcuts import render
from .models import Question
# Create your views here.
def add(request):
    if request.method == "GET":
        return render(request, 'add.html')
    if request.method == "POST":
        title = request.POST.get('title')
        qtype = request.POST.get('qtype')
        option1 = request.POST.get('option1')
        option2 = request.POST.get('option2')
        option3 = request.POST.get('option3')
        option4 = request.POST.get('option4')
        ref_answer = request.POST.get('ref_answer')
        analysis = request.POST.get('analysis')
        q1 = Question(title=title, qtype=qtype,option1=option1,option2=option2,option3=option3,option4=option4,ref_answer=ref_answer,analysis=analysis)
        q1.save()
        result = "添加成功"
        return render(request, 'add.html', {"result": result})
